# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/27 下午3:47
 @Author  : tgy
 
"""

def test01():
    x = 10
    print(locals())
    print(locals()['x'])
    # 修改不起作用
    locals()['x'] = 101
    print(locals()['x'])
    globals()

print(id(globals()))
print(id(locals()))

def test02():
    ...
    print(id(globals()))
    print(id(locals()))


y = 10

def test03():
    ...
    print(globals()['y'])
    del globals()['y']

class Person:

    opt = 1

    def __init__(self):
        # print(locals())
        print(dir())

    def __dir__(self):
        return ['opt']

if __name__ == '__main__':
    ...
    # test03()
    print(y)
    p = Person()
    print(dir(p))
    print(globals())
    print(dir())